/*
 * LDIR
 * 
 * LDIR, a GPS cartography application built for Let's Do It Romania eco 
 * campaign.
 * Copyright (C) 2010 Genera Software <office@generasoftware.com>
 * 
 * http://generasoftware.com/
 * 
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation; either version 2 of the License, or (at your option) any later
 * version.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
 * Place, Suite 330, Boston, MA 02111-1307 USA
 */
#include <aknviewappui.h>
#include <eikmenub.h>
#include <avkon.hrh>
#include <akncontext.h>
#include <akntitle.h>
#include <stringloader.h>
#include <barsread.h>
#include <LDIR.rsg>

#include "LDIR.hrh"
#include "LDIRSplashView.h"
#include "LDIRSplash.h"
/**
 * First phase of Symbian two-phase construction. Should not contain any
 * code that could leave.
 */
CLDIRSplashView::CLDIRSplashView()
    {
    iLDIRSplash = NULL;
    }

/** 
 * The view's destructor removes the container from the control
 * stack and destroys it.
 */
CLDIRSplashView::~CLDIRSplashView()
    {
    delete iLDIRSplash;
    iLDIRSplash = NULL;
    }

/**
 * Symbian two-phase constructor.
 * This creates an instance then calls the second-phase constructor
 * without leaving the instance on the cleanup stack.
 * @return new instance of CLDIRSplashView
 */
CLDIRSplashView* CLDIRSplashView::NewL()
    {
    CLDIRSplashView* self = CLDIRSplashView::NewLC();
    CleanupStack::Pop( self );
    return self;
    }

/**
 * Symbian two-phase constructor.
 * This creates an instance, pushes it on the cleanup stack,
 * then calls the second-phase constructor.
 * @return new instance of CLDIRSplashView
 */
CLDIRSplashView* CLDIRSplashView::NewLC()
    {
    CLDIRSplashView* self = new ( ELeave ) CLDIRSplashView();
    CleanupStack::PushL( self );
    self->ConstructL();
    return self;
    }


/**
 * Second-phase constructor for view.  
 * Initialize contents from resource.
 */ 
void CLDIRSplashView::ConstructL()
    {
    BaseConstructL( R_LDIRSPLASH_LDIRSPLASH_VIEW );
    // add your own initialization code here
    }

/**
 * @return The UID for this view
 */
TUid CLDIRSplashView::Id() const
    {
    return TUid::Uid( ELDIRSplashViewId );
    }

/**
 * Handle a command for this view (override)
 * @param aCommand command id to be handled
 */
void CLDIRSplashView::HandleCommandL( TInt aCommand )
    {
	TBool commandHandled = EFalse;
	switch ( aCommand )
		{	// code to dispatch to the AknView's menu and CBA commands is generated here
		default:
			break;
		}
	
		
	if ( !commandHandled ) 
		{
		// dispatch to handleCommand handler
		commandHandled = HandleSplashViewCommandL( aCommand );
			
		if ( !commandHandled ) 
			{
			if ( aCommand == EAknSoftkeyExit )
				{
				AppUi()->HandleCommandL( EEikCmdExit );
				}
			}
		}
    }

/**
 *    Handles user actions during activation of the view, 
 *    such as initializing the content.
 */
void CLDIRSplashView::DoActivateL( 
        const TVwsViewId& /*aPrevViewId*/,
        TUid /*aCustomMessageId*/,
        const TDesC8& /*aCustomMessage*/ )
    {
    if ( iLDIRSplash == NULL )
        {
        iLDIRSplash = CreateContainerL();
        iLDIRSplash->SetMopParent( this );
        AppUi()->AddToStackL( *this, iLDIRSplash );
        } 
    }

/**
 */
void CLDIRSplashView::DoDeactivate()
    {
    if ( iLDIRSplash != NULL )
        {
        AppUi()->RemoveFromViewStack( *this, iLDIRSplash );
        delete iLDIRSplash;
        iLDIRSplash = NULL;
        }
    }

/**
 *    Creates the top-level container for the view.  You may modify this method's
 *    contents and the CLDIRSplash::NewL() signature as needed to initialize the
 *    container, but the signature for this method is fixed.
 *    @return new initialized instance of CLDIRSplash
 */
CLDIRSplash* CLDIRSplashView::CreateContainerL()
    {
    return CLDIRSplash::NewL( AppUi()->ApplicationRect(), NULL, this );
    }

/** 
 * Handle the handleCommand event.
 * @return ETrue if event was handled, EFalse if not
 */
TBool CLDIRSplashView::HandleSplashViewCommandL(TInt aCommand)
	{
	if (aCommand == ECmdSplashCompleted)
		{
		AppUi()->HandleCommandL(ECmdSplashCompleted);
		return ETrue;
		}
	return EFalse;
	}

